<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>Jsonp (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">net.Jsonp</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">
            Object</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Creates a new cross domain channel that sends data to the specified
host URL. By default, if no reply arrives within 5s, the channel
assumes the call failed to complete successfully.
  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_net_jsonp.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<pre class="inheritance">
Object
     <img src="static/images/inherit.gif">goog.net.Jsonp
</pre>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.net.Jsonp(<span><span class="arg">uri</span>,&nbsp;<span class="arg">opt_callbackParamName</span></span>)
  </div>

   <h3>Parameters</h3>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">uri</span>
        : <div class="fullType"><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span><span>&nbsp;|&nbsp;</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The Uri of the server side code that receives data posted through this channel (e.g., &quot;<a href="http://maps.google.com/maps/geo">http://maps.google.com/maps/geo</a>&quot;).</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_callbackParamName</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The parameter name that is used to specify the callback. Defaults to &quot;callback&quot;.</div>
     </td>
   </tr>
  </table>


<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_net_Jsonp.html">
              goog.net.Jsonp
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.cancel"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">cancel<span class="args">(<span class="arg">request</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Cancels a given request. The request must be exactly the object returned by
the send method.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">request</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The request object returned by the send method.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line227">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.getRequestTimeout"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">getRequestTimeout<span class="args">()</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
      </div>


     <div class="entryOverview">
       Returns the current timeout value, in milliseconds.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>&nbsp;
            The timeout value.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line127">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.send"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">send<span class="args">(<span class="arg">payload</span>,&nbsp;<span class="arg">opt_replyCallback</span>,&nbsp;<span class="arg">opt_errorCallback</span>,&nbsp;<span class="arg">opt_callbackParamValue</span>)</span>
        </span>
        &#8658; <div class="fullType"><span>?</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
      </div>


     <div class="entryOverview">
       Sends the given payload to the URL specified at the construction
time. The reply is delivered to the given replyCallback. If the
errorCallback is specified and the reply does not arrive within the
timeout period set on this channel, the errorCallback is invoked
with the original payload.

If no reply callback is specified, then the response is expected to
consist of calls to globally registered functions. No &amp;callback=
URL parameter will be sent in the request, and the script element
will be cleaned up after the timeout.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">payload</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">Name-value pairs.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_replyCallback</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">A function expecting one argument, called when the reply arrives, with the response data.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_errorCallback</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">A function expecting one argument, called on timeout, with the payload.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_callbackParamValue</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">Value to be used as the parameter value for the callback parameter (callbackParamName). To be used when the value needs to be fixed by the client for a particular request, to make use of the cached responses for the request. NOTE: If multiple requests are made with the same opt_callbackParamValue, only the last call will work whenever the response comes back.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span>?</span><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>&nbsp;
            A request descriptor that may be used to cancel this transmission, or null, if the message may not be cancelled.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line163">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.prototype.setRequestTimeout"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">setRequestTimeout<span class="args">(<span class="arg">timeout</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Sets the length of time, in milliseconds, this channel is prepared
to wait for for a request to complete. If the call is not competed
within the set time span, it is assumed to have failed. To wait
indefinitely for a request to complete set the timout to a negative
number.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">timeout</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span></div>
        <div class="entryOverview">The length of time before calls are interrupted.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line117">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>














<h2>Static Methods</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.addPayloadToUri_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">addPayloadToUri_<span class="args">(<span class="arg">payload</span>,&nbsp;<span class="arg">uri</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span></div>
      </div>


     <div class="entryOverview">
       Returns URL encoded payload. The payload is assumed to be a list of
value name pairs, in the form {&quot;foo&quot;: 1, &quot;bar&quot;: true, ...}.

<p>The method uses hasOwnProperty() to assure the properties are on the
object, not on its prototype.</p>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">payload</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">A list of value name pairs to be encoded. A value may be specified as an array, in which case a query parameter will be created for each value, e.g.: {&quot;foo&quot;: [1,2]} will encode to &quot;foo=1&amp;foo=2&quot;.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">uri</span>
        : <div class="fullType"><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span></div>
        <div class="entryOverview">A Uri object onto which the payload key value pairs will be encoded.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="class_goog_Uri.html">goog.Uri</a></span></div>&nbsp;
            A reference to the Uri sent as a parameter.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line347">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.cleanup_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">cleanup_<span class="args">(<span class="arg">id</span>,&nbsp;<span class="arg">scriptNode</span>,&nbsp;<span class="arg">deleteReplyHandler</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Removes the script node and reply handler with the given id.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">id</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The id of the script node to be removed.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">scriptNode</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Node">Node</a></span></div>
        <div class="entryOverview">The node to be removed.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">deleteReplyHandler</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
        <div class="entryOverview">If true, delete the reply handler instead of setting it to nullFunction (if we know the callback could never be called again).</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line310">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.newErrorHandler_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">newErrorHandler_<span class="args">(<span class="arg">id</span>,&nbsp;<span class="arg">scriptNode</span>,&nbsp;<span class="arg">payload</span>,&nbsp;<span class="arg">opt_errorCallback</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
      </div>


     <div class="entryOverview">
       Creates a timeout callback that removes the script node and calls
the given timeoutCallback with the original payload.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">id</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The id of the script node.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">scriptNode</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Element">Element</a></span></div>
        <div class="entryOverview">Script element.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">payload</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">The payload that was sent to the server.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_errorCallback</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">The function called on timeout.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>&nbsp;
            A zero argument function that handles callback duties.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line252">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.net.Jsonp.newReplyHandler_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.net.Jsonp.</span><span class="entryName">newReplyHandler_<span class="args">(<span class="arg">id</span>,&nbsp;<span class="arg">scriptNode</span>,&nbsp;<span class="arg">replyCallback</span>,&nbsp;<span class="arg">timeout</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
      </div>


     <div class="entryOverview">
       Creates a reply callback that removes the script node and calls the
given replyCallback with data returned by the server.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">id</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span></div>
        <div class="entryOverview">The id of the script node.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">scriptNode</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/DOM/Element">Element</a></span></div>
        <div class="entryOverview">Script element.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">replyCallback</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>
        <div class="entryOverview">The function called on reply.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">timeout</span>
        : <div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span></div>
        <div class="entryOverview">A timeout call that needs to be cleared.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="http://www.google.com/url?sa=D&q=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function">Function</a></span></div>&nbsp;
            A reply callback function.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_net_jsonp.js.source.html#line281">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package net</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="goog" current="net.Jsonp"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
